<?php

namespace App\Services\Formatter;

use App\Common\Helper;
use App\Model\User;
use Carbon\Carbon;

class UserFormatter
{
    public function stdoutFormatter(User $user): array
    {
        return [
            'userId' => $user->id,
            'username' => $user->username,
            'nickname' => $user->nickname,
            'phone' => Helper::instance()->hidePhone(Helper::instance()->decryptCbcStr($user->phone, $user->phone_iv)),
            'gender' => $user->changeGender($user->gender),
            'wechatCode' => $user->wechat_code,
            'email' => $user->email,
            'headerImage' => $user->header_image,
            'IDCard' => Helper::instance()->decryptCbcStr($user->id_number, $user->id_number_iv),
            'profession' => $user->changeProfession($user->profession),
            'createTime' => Carbon::parse($user->created_at)->format('Y-m-d H:i:s'),
            'updateTime' => Carbon::parse($user->updated_at)->format('Y-m-d H:i:s'),
        ];
    }
}